@extends('admin.inc.base')
@section('content')
    <link rel="stylesheet" type="text/css" href="/public/statics/libs/wangEditor/dist/css/wangEditor.min.css">
    <script type="text/javascript" src="/public/statics/libs/wangEditor/dist/js/wangEditor.js"></script>
    <script type="text/javascript" src="/public/statics/libs/uploader/UploadFile.js"></script>

        <div class="panel panel-default">
            <div class="panel-heading">
                编辑广告
            </div>
            <div class="panel-body">
                <form action="/admin/ad" method="post">
                    <div class="form-group">
                        <label for="">标题</label>
                        <input type="text" class="form-control" name="title"  placeholder="标题">
                    </div>

                    <div class="form-group">
                        <label for="">链接</label>
                        <input type="text" class="form-control" name="url"  placeholder="链接">
                        <p class="help-block"></p>
                    </div>

                    <div class="form-group">
                        <label for="">广告位置</label>
                        <input type="text" class="form-control" name="position"  placeholder="广告位置">
                        <p class="help-block">标志位置的数字，用于模板页面引用对应的广告。需要保证数字唯一</p>
                    </div>

                    <div class="form-group">
                        <label for="">广告图</label>
                        <div id="upload-img-show">

                        </div>
                        <span class="upload" id="upload">上传图片</span>
                        <input type="hidden" name="cover" id="upload-img"/>
                        <p class="help-block">根据广告位置上传相应大小</p>
                    </div>




                    <button type="submit" class="btn btn-default">提交</button>
                </form>
            </div>
        </div>
    <script type="text/javascript">
        var upload = new Upload({
            "clickDom":"upload",
            "action":"/admin/upload",
            "onUploadSuccess":function(data){
                if(data.status == 'ok'){
                    $('#upload-img').val(data.url);
                    $("#upload-img-show").html('<img src="'+data.url+'" />');
                }else{
                    console.log(data);
                }
            }
        });
    </script>
@endsection